home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SGI Developer Toolbox 6.1
/
SGI Developer Toolbox 6.1 - Disc 4.iso
/
src
/
haeberli
/
objtools
/
sterrend.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-08-01
|
3KB
|
124 lines
/*
* Copyright 1991, 1992, 1993, 1994, Silicon Graphics, Inc.
* All Rights Reserved.
*
* This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
* the contents of this file may not be disclosed to third parties, copied or
* duplicated in any form, in whole or in part, without the prior written
* permission of Silicon Graphics, Inc.
*
* RESTRICTED RIGHTS LEGEND:
* Use, duplication or disclosure by the Government is subject to restrictions
* as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
* and Computer Software clause at DFARS 252.227-7013, and/or in similar or
* successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
* rights reserved under the Copyright Laws of the United States.
*/
/*
* sterrend -
* Render a object to be viewed with stereo glasses.
*
* Paul Haeberli - 1989
*/
#include "gl.h"
#include "device.h"
#include "math.h"
#include "sgiobj.h"
#include "stdio.h"
#define XDELTA (0.1)
#define YDELTA (0.0)
float fgetmousex();
float fgetmousey();
float xrot, yrot;
float tran, p;
sgiobj* obj;
int drawworld();
main(argc,argv)
int argc;
char **argv;
{
int i;
float param;
short val;
float xdelta;
if(argc<2) {
fprintf(stderr,"usage: sterrend obj.sgo\n");
exit(1);
}
obj = readsgiobj(argv[1]);
if(!obj) {
fprintf(stderr, "sterrend: can't read %s\n",argv[1]);
exit(1);
}
p = 0.0;
xrot = yrot = 0;
tran = -5.0;
keepaspect(5,4);
winopen("sterrend");
RGBmode();
doublebuffer();
gconfig();
RGBcolor(128,128,128);
clear();
swapbuffers();
clear();
zbuffer(1);
backface(1);
matinit();
matrixinit();
renderperspective(250,5.0/4.0,0.1,100.0);
shadeinit();
qdevice(LEFTMOUSE);
qdevice(MIDDLEMOUSE);
xdelta = XDELTA;
while(1) {
if(getbutton(MIDDLEMOUSE))
xdelta = fgetmousex()/10.0;
else {
xrot = fgetmousex();
yrot = fgetmousey();
}
zclear();
RGBwritemask(0xff,0x00,0x00);
accset(0.0,0.0,-xdelta,-YDELTA);
drawworld();
zclear();
RGBwritemask(0x00,0xff,0xff);
accset(0.0,0.0,xdelta,-YDELTA);
drawworld();
swapbuffers();
while(qtest()) {
switch(qread(&val)) {
case REDRAW:
reshapeviewport();
break;
}
}
}
}
drawworld()
{
pushmatrix();
translate(0.0,0.0,tran);
rgb(0.05,0.05,0.05);
clear();
rot(360.0*xrot,'x');
rot(360.0*yrot,'y');
scale(2.0,2.0,2.0);
shadeon();
setdiffuse(0.5,0.5,0.5);
setspecular(0.7,0.7,0.7);
setshininess(20.0);
drawsgiobj(obj,DRAW_POINTS|DRAW_NORMALS);
shadeoff();
popmatrix();
}